Testing Conditions
Previous  Top  Next



The Clip language includes many commands and functions to test conditions within the NoteTab environment. You can use these tests to control which instructions are executed based on one condition or another. See below the commands and functions that are available for controlling the operational flow:

Note that NoteTab Light 4.6 and earlier (with trial mode not enabled) only supports the predefined label "Exit".

New since NoteTab 4.8: conditional commands now accept a command statement instead of a label. The second command statement may not be another conditional command, and it may not be followed by an ELSE-type label. Examples:
^!If ^%Variable% < 0 ^!Set %Variable%=0
^!IfFileExist "^%Variable%" GoToLabelTrue ELSE ^!Prompt File does not exist


Commands:

^!Continue
[Question]
Displays a message box with an OK and Cancel button. If the user clicks on the OK button, the Clip execution continues normally. If the Cancel button is pressed then Clip execution is halted at that point. NoteTab checks if this instruction is the first to execute in a Clip; if this is the case it will be displayed before the main Clip Wizard (if any).

^!If Integer1 <>= Integer2 GoToLabelTrue [ELSE GoToLabelFalse]
or
^!If "String1" <>= "String2" GoToLabelTrue [ELSE GoToLabelFalse]
If the comparison result is true, then jumps to the specified GoToLabelTrue label. If the result is false and the optional ELSE keyword follows the first label name, execution jumps to the specified GoToLabelFalse label; or to the next instruction if the "ELSE" label is not used. If the two values represent numbers then they are compared as numbers, otherwise they are compared as strings. String comparison is case sensitive.
You can use the following comparison operators:
<
   returns True if left value is smaller than right value
>
   returns True if left value is greater than right value
<>
   returns True if left value is different from right value
<=
   returns True if left value is smaller or equal to right value
>=
   returns True if left value is greater or equal to right value
=
   returns True if left value is equal to right value

Examples:
The following will cause the execution to jump to the label defined as IsTrue:
^!If "Apple" <> "Orange" IsTrue ELSE IsFalse
The following will cause the execution to jump to the label defined as LabelFalse:
^!If 16 < 7 LabelTrue ELSE LabelFalse

^!IfAppOpen AppTitle GoToLabelTrue [ELSE GoToLabelFalse] (added in v4.52)
Jumps to the specified label if a window with the indicated title caption is found. For example, if the Windows calculator utility is open, the following command will continue execution after the CalcOpen label:
^!IfAppOpen Calculator CalcOpen
Most applications usually show other information in the title bar. For these cases, you can use an asterisk "*" either at the beginning or the end of the AppTitle text to specify that the text should match the end or the beginning of the title respectively. For example, MS Wordpad displays the document name in front of the program name, so the following instruction will work if Wordpad is open:
^!IfAppOpen *WordPad WordPadOpen

^!IfCancel GoToLabel
Jumps to specified label if a Clip Wizard built from "^?{}" fields has been canceled. If the Clip doesn't contain such a statement or if it does not appear after the call to the Clip Wizard and before the next one, then its execution is aborted.

^!IfClipExist "ClipName" GoToLabelTrue [ELSE GoToLabelFalse]
Jumps to label if the specified Clip exists.

^!IfDiff "Value1" "Value2" GoToLabelTrue [ELSE GoToLabelFalse]
Compares two string values. The comparison is not case sensitive.
Example:
The following will cause the execution to skip the next instruction (Skip is a predefined label):
^!IfDiff "abc" "xyz" Skip


^!IfError GoToLabelTrue [ELSE GoToLabelFalse]
If the previous command fails for one reason or another, it sets an error state that can be detected with "^!IfError". If the previous command failed, then execution will jump to specified label. Note that support for ELSE was added in NoteTab v4.51.

^!IfFalse Value GoToLabelTrue [ELSE GoToLabelFalse]
If Value is an empty string or equal to 0, FALSE, NO, N, or OFF (case insensitive), then jumps to specified label name. Do not use comparison operators with this command; in that case, you should use the ^!If command to do a comparison between two values.

^!IfFileAttr "FileName" Attr GoToLabelTrue [ELSE GoToLabelFalse] (added in v4.8)
Compares FileName attributes with Attr. If Attr is equal or a subset of FileName's attributes, then GoToLabelTrue is activated. Attr can represent multiple values: A = Archive, D = Directory, H = Hidden, R = Read-only, S = System, V = VolumeID, * = All attributes. Example:
^!IfFileAttr "c:\Scandisk.log" AH LabelTrue ELSE LabelFalse

If Scandisk.log has at least the Archive and Hidden attributes set, then the instruction jumps to LabelTrue.

^!IfFileExist "FileName" GoToLabelTrue [ELSE GoToLabelFalse]
Jumps to specified label if FileName exists.

^!IfInDateRange yyyy/mm/dd-hh:nn yyyy/mm/dd-hh:nn..yyyy/mm/dd-hh:nn GoToLabelTrue [ELSE GoToLabelFalse]
Similar to IfInRange command but takes dates as arguments instead of integers. The date value can have the following formats (yyyy=year, mm=month, dd=day, hh=24 hour, nn=minutes):
yyyy/mm/dd-hh:nn
1998/07/13-16:30
yyyy/mm/dd
1998/07/13
hh:nn
16:30

^!IfInRange Value Range1..Range2 GoToLabelTrue [ELSE GoToLabelFalse]
Applies only to numerical values. If Value is in the range defined from Range1 to Range2, then jumps to GoToLabelTrue. For example: "^!IfInRange 23 20..30 DoThis" will jump to the label ":DoThis"

^!IfLabelExist LabelName GoToLabelTrue [ELSE GoToLabelFalse] (added in v4.52)
Jumps to the specified label if the indicated label name exists in the active Clip.

^!IfMatch "RegExp" "Value2" GoToLabelTrue [ELSE GoToLabelFalse] (added in v4.8)
Similar to ^!IfSame, but accepts a regular expression for the first value.

^!IfPathExist "PathName" GoToLabelTrue [ELSE GoToLabelFalse]
Jumps to specified label if PathName exists.

^!IfSame "Value1" "Value2" GoToLabelTrue [ELSE GoToLabelFalse]
Compares two string values. The comparison is not case sensitive.
Example:
The following will cause the execution to jump to the label defined as GoToLabelTrue:
^!IfSame "abc" "ABC" GoToLabelTrue

^!IfTrue Value GoToLabelTrue [ELSE GoToLabelFalse]
If Value is equal to 1, TRUE, YES, Y, or ON (case insensitive), then jumps to specified label name. Do not use comparison operators with this command; in that case, you should use the ^!If command to do a comparison between two values.

^!Skip Question
Skips next instruction if the user answers Yes.


Functions:

^$IsAlpha("Str")$ (added in v4.8)
Returns 1 if Str contains only characters from the alphabet, and 0 if it does not.

^$IsAlphaNumeric("Str")$ (added in v4.8)
Returns 1 if Str contains only numbers and characters from the alphabet, and 0 if it does not.

^$IsAltKeyDown$ (added in v4.8)
Returns 1 if the Alt key is pressed while the function is executed and 0 if it is not.

^$IsAutoIndent$
Returns 1 if AutoIndent is enabled in current document and 0 if it is turned off.

^$IsBlank("Str")$ (added in v4.8)
Returns 1 if Str contains only blank characters (tabs, spacebar, line breaks, etc.), and 0 if it does not.

^$IsCapitalized("Str")$ (added in v4.8)
Returns 1 if Str does not start with a lowercase character and is not followed by any uppercase characters, and 0 if this condition is not met.

^$IsClipDoc$
Returns 1 if current document is the [Clip] editor, or 0 if it is not.

^$IsCtrlKeyDown$ (added in v4.8)
Returns 1 if the Control key is pressed while the function is executed and 0 if it is not.

^$IsEmpty(Value)$
Returns 1 if the value/variable is empty and 0 if it contains data.

^$IsFileType("FileName";"extensions")$
Returns 1 if the extension of FileName is listed in "extensions", or 0 if turned off. Multiple extensions must be delimited with a comma. The following example returns 1:
^$IsFileType("c:\temp\MyFile.txt";"html,txt,otl,ini")

^$IsFullVersion$
Returns 1 if NoteTab is the commercial version and 0 if it is the Freeware or trial version.

^$IsHex(Value)$ (added in v4.52)
Returns 1 if specified text is a hexadecimal number and 0 if it is not.

^$IsHtmlDoc$
Returns 1 if current document is HTML type document, or 0 if it is not.

^$IsLightVersion$
Returns 1 if the NoteTab program currently running is the Freeware version (trial mode not enabled), or 0 if it is not.

^$IsLowercase("Str")$ (added in v4.8)
Returns 1 if Str does not contain any uppercase characters, and 0 if it does.

^$IsMixedCase("Str")$ (added in v4.8)
Returns 1 if Str contains both lowercase and uppercase characters, and 0 if it does not. Note that text that is capitalized is not considered mixed case.

^$IsModified$
Returns 1 if current document needs saving, or 0 if it is not modified.

^$IsNumber(Value)$
Returns 1 if specified text is a number and 0 if it is not.

^$IsOpen("DocumentName")$
Returns 1 if specified document is open in NoteTab and 0 if it is not.

^$IsOutlineDoc$
Returns 1 if current document is Outline type document, or 0 if it is not.

^$IsPasteBoard$
Returns 1 if current document is the Paste Board, or 0 if it is not.

^$IsPasteIndent$ (added in v4.8)
Returns 1 if Clips insert text with automatic indenting and 0 if not.

^$IsReadOnly$
Returns 1 if current document is Read-Only, or 0 if it is not.

^$IsSecondWindow$
Returns 1 if current document is in the second window, or 0 if it is not.

^$IsShiftKeyDown$ (added in v4.8)
Returns 1 if the Shift key is pressed while the function is executed and 0 if it is not.

^$IsShowHeadings$ (added in v4.52)
Returns 1 if headings are displayed in the outline document window and 0 if they are not.

^$IsTopStyleEnabled$ (added in v4.8)
Returns 1 if the TopStyle editor is available through NoteTab, and 0 if it is not.

^$IsTrimBlanks$ (added in v4.6)
Returns 1 if the option "Trim White Spaces" is enabled in current document and 0 if it is turned off.

^$IsUppercase("Str")$ (added in v4.8)
Returns 1 if Str does not contain any lowercase characters, and 0 if it does.

^$IsUrl("AnyText")$
Tests if parameter is a URL or not. It returns 1 to indicate True and 0 to indicate False.

^$IsWildcard("FileName")$ (added in v4.82)
Returns 1 if FileName contains one or more wildcard characters (* and ?), and 0 if it does not.

^$IsWordWrap$
Returns 1 if word wrap is active in current document, or 0 if turned off.